﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NodeTemp.aspx.cs" Inherits="Workflow.Project.NodeTemp" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table class="table table-bordered table-hover definewidth m10">
            <tr>
                <td class="tableleft">项目号</td>
                <td><input id="txtNo" type="text" runat="server" />
                    <asp:Button ID="Search" CssClass="btn btn-primary" Visible="false" runat="server" Text="查询" OnClick="Search_Click"></asp:Button>
                </td>
                <td></td>
            </tr>
            <% if(resultList.Count>0){ %>
                <tr>
                    <td class="tableleft"><label class="lblName">更改原因</label></td>
                    <td>
                        <asp:TextBox ID="txtReason" CssClass="DateValue" runat="server" Height="72px" TextMode="MultiLine" Width="245px" Enabled="false"></asp:TextBox>
                    </td>
                    <td></td>
                </tr>
                <tr>
                    <td class="tableleft"><label class="lblName" >同步</label></td>
                    <td>
                        <asp:TextBox ID="txtData" runat="server" Enabled="false"></asp:TextBox>
                    </td>
                    <td></td>
                </tr>
                <tr>
                    <td class="tableleft">节点名</td>
                    <td class="tableleft">阶段属性</td>
                    <td class="tableleft">阶段完成时间</td>
                </tr>
            <% } %>
            

                <% if(resultList.Count>0){ %>
                    <% for (int i = 0; i < resultList.Count; i++){ %>
                        <tr>
                            <td class="tableleft"><label id="lbl<%= i%>" class="lblName" title="<%=resultList[i].NodeName %>"><%=resultList[i].NodeName %></label></td>
                            <td>
                                <label id="<%= i%>" class="lblName" title="<%=resultList[i].Content %>"><%=resultList[i].Content %>阶段</label>
                            </td>
                            <td>
                                <input id="txt<%= i%>" disabled="disabled" type="date" class="DateValue" style="width:174px" />
                            </td>
                        </tr>
                    <% } %>
                    
                    
                <% }%>
            <tr>
                <td class="tableleft"></td>
                <td>
                    <button id="Btn1" class="btn btn-primary" visible="false" runat="server">确定</button>
                    <button id="Btn2" class="btn btn-primary" visible="false" runat="server">确定</button>
                    <asp:Button ID="Btn3" CssClass="btn btn-primary" Visible="false" runat="server" Text="同步" OnClick="Btn3_Click"></asp:Button>
                    <asp:Button ID="Btn4" CssClass="btn btn-primary" Visible="false" runat="server" Text="删除" OnClick="Btn4_Click"></asp:Button>
                </td>
                <td></td>
            </tr>
         </table>  
    </div>
    </form>
    <script>
        $(document).ready(function () {
            <% if(resultList.Count>0){ %>
                <% for(int i=0;i<resultList.Count;i++){%>
                $("#<%= i%>").val("<%= resultList[i].Content%>");
                $("#txt<%= i%>").val("<%= resultList[i].CompleteDate.ToString("yyyy-MM-dd")%>");
                    <%if(pjCount>0 && statusNo < 1){%>
                        $("#txt<%= i%>").removeAttr("disabled");
                    <%}%>
                <%}%>
            <%}%>
            return false;
        });
        function Validate() {
            var count = parseInt(<%=listCount %>);
            for (var i = 0; i < count; i++) {
                var sId = i;
                var tValue = $("#txt" + sId).val();
                var label = $("#lbl" + sId).attr("title");
                if (tValue == "") {
                    alert(label + "阶段完成时间不能为空");
                    a = 1;
                    return false;
                }
            }
        }
    </script>
    <script>
        $(document).ready(function () {
            a = 0;
            $("#Btn1").click(function () {
                Validate();
                if (a == 1) {
                    return false;
                }
                $(this).attr("disabled", "true");
                var count = parseInt(<%=listCount %>);
                var sValue = "";
                var tValue = "";
                var label = "";
                var number = "";
                for (var i = 0; i < count; i++) {
                    var sId = i;
                    sValue = sValue + $("#" + sId).attr("title") + ",";
                    tValue = tValue + $("#txt" + sId).val() + ",";
                    var no = $("#txtNo").val().trim();
                    label = label + $("#lbl" + sId).attr("title") + ",";
                    number = number + i + ",";
                }
                sValue = sValue.substring(0, sValue.length - 1);
                tValue = tValue.substring(0, tValue.length - 1);
                label = label.substring(0, label.length - 1);
                number = number.substring(0, number.length - 1);
                var reason = $("#txtReason").val().trim();
                var url = "PJServer.ashx?Type=createTemp&WorkParentId=<%=workParentId %>&SelectValue=" + sValue + "&TextValue=" + tValue + "&PJId=" + no + "&LabelValue=" + label + "&Number=" + number + "&Reason=" + reason;
                $.ajax({
                    type: "Get",
                    url: url,
                    success: function (data) {
                        alert(data);
                        window.opener.location.reload();
                        window.close();
                    }
                });


                return false;
            });
            $("#Btn2").click(function () {
                Validate();
                if (a == 1) {
                    return false;
                }
                $(this).attr("disabled", "true");
                var count = parseInt(<%=listCount %>);
                var sValue = "";
                var tValue = "";
                var label = "";
                var number = "";
                for (var i = 0; i < count; i++) {
                    var sId = i;
                    sValue = sValue + $("#" + sId).attr("title") + ",";
                    tValue = tValue + $("#txt" + sId).val() + ",";
                    var no = $("#txtNo").val().trim();
                    label = label + $("#lbl" + sId).attr("title") + ",";
                    number = number + i + ",";
                }
                sValue = sValue.substring(0, sValue.length - 1);
                tValue = tValue.substring(0, tValue.length - 1);
                label = label.substring(0, label.length - 1);
                number = number.substring(0, number.length - 1);
                var reason = $("#txtReason").val().trim();
                var url = "PJServer.ashx?Type=changeTemp&WorkParentId=<%=workParentId %>&SelectValue=" + sValue + "&TextValue=" + tValue + "&PJId=" + no + "&LabelValue=" + label + "&Number=" + number + "&Reason=" + reason;
                $.ajax({
                    type: "Get",
                    url: url,
                    success: function (data) {
                        alert(data);
                        window.opener.location.reload();
                        window.close();
                    }
                });
                return false;
            });

        });
    </script>
</body>
</html>
